<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/TemplateUsuario.xhtml">

    <ui:define name="body">
		<h1><h:outputText value="#{messages.autoresMaisSeguidos}" /></h1>
		<h:form>
			<rich:panel header="Filtrar Autores">
				<h:panelGrid columns="2">
					<h:outputLabel for="tagPesquisa" value="Tag do Autor: " />
					<h:inputText id="tagPesquisa" value="#{listarAutorCtrl.pesquisaTag.id}" size="30" />
					<rich:suggestionbox id="stbTag" for="tagPesquisa" height="200" width="200" 
					  suggestionAction="#{listarCtrl.autocompleteTagSuggestionBox}" 
					  nothingLabel="Nenhuma Tag encontrada" var="result">
						<h:column>
							<h:outputText value="#{result.id}" />
						</h:column>
					</rich:suggestionbox>
				</h:panelGrid>
				<h:panelGroup>
					<h:commandButton action="#{listarAutorCtrl.pesquisarAutores}" value="#{messages.actionBuscar}" />
					<rich:spacer width="5" />
					<h:commandButton action="#{listarAutorCtrl.limparPesquisaAutores}" value="#{messages.actionLimpar}" />
				</h:panelGroup>
			</rich:panel>
			
			<div style="clear:both" />
			
			<rich:spacer height="20" />
			
			<h:panelGroup rendered="#{empty listarAutorCtrl.autoresMaisSeguidos}">
				<h:outputText value="#{messages.nenhumAutorEncontrado}"  />
			</h:panelGroup>
			
			<rich:simpleTogglePanel switchType="client" height="400" width="600" rendered="#{not empty listarAutorCtrl.autoresMaisSeguidos}">
				<s:div style="height: 400px;">
					
					<rich:dataTable value="#{listarAutorCtrl.autoresMaisSeguidos}" var="autor">
					
						<f:facet name="header">
							<rich:columnGroup>
								<rich:column>
									<h:outputText value="Autor" />
								</rich:column>
								<rich:column>
									<h:outputText value="Seguidores" />
								</rich:column>
							</rich:columnGroup>
						</f:facet>
						
						<rich:column>
							<ui:include src="/Autor.xhtml">
								<ui:param name="autor" value="#{autor}" />
							</ui:include>
						</rich:column>
						
						<rich:column style="text-align: center;">
							<h:outputText value="#{autor.quantidadeFavoritos}" rendered="#{not empty autor.quantidadeFavoritos}" />
							<h:outputText value="0" rendered="#{empty autor.quantidadeFavoritos}" />
						</rich:column>
						
					</rich:dataTable>
				</s:div>
			</rich:simpleTogglePanel>
		</h:form>
    </ui:define>
</ui:composition>
